// subPages/health/analysis/analysis.js
const app = getApp()
var util =  require('../../../utils/healthUtil.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    low: '<',
    height: '>',
    isShow: false
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    if(options.item != 'undefined' && options.item != null)
    {
      this.setData({
        isNewUser: 2,
        userInfo: JSON.parse(options.item)
      })
      wx.setNavigationBarTitle({
        title: this.data.userInfo.nickName + '的数据分析' //页面标题为路由参数
      })
    }else{
      this.setData({
        isNewUser: 1,
        userInfo: app.globalData.userInfo,
      })
    }
    this.getAnalyisList(options);
  },
  
  getAnalyisList(options){
    var that = this
    // console.log(options.id)
    wx.request({
        url: app.globalData.apiUrl +'/get_user_one',
        data: {
          id: options.id,
          yes: options.yes
        },
        method: 'get',
        header: {
          'content-type': 'application/json' //默认值
        },
        success: function (res) {
          console.log(res);
          if(res.statusCode == 200){
            that.setData({
              normalList:res.data.bz,
              heightList:res.data.height,
              lowList:res.data.low,
              createtime: res.data.ttt,
              normalindex:res.data.bz.length,
              heightindex:res.data.height.length,
              lowindex:res.data.low.length,
            })
            that.setNormalMeasuringRange(that.data.normalList)
            that.setheightMeasuringRange(that.data.heightList)
            that.setlowMeasuringRange(that.data.lowList)
            that.setBzUnit(that.data.normalList);
            that.setLowUnit(that.data.lowList);
            that.setHeightUnit(that.data.heightList);
          }
        },
        fail: function (res) {
          console.log("失败");
        }
    })
  },

  //设置正常列表的区间
  setNormalMeasuringRange:function(normalList){
    var that = this
    for(var i in normalList)
    {
      if(normalList[i].title == '体重')
      {
        var isShow = "normalList[" + i + "].isShow"
        var imgsrc = "normalList[" + i + "].imgsrc"
        var titleImgSrc = "normalList[" + i + "].titleImgSrc"
        var MeasuringRange = "normalList[" + i + "].MeasuringRange"
        var text = "normalList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/weight.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(normalList[i])
        })
      }
      if(normalList[i].title == 'BMI')
      {
        var isShow = "normalList[" + i + "].isShow"
        var imgsrc = "normalList[" + i + "].imgsrc"
        var titleImgSrc = "normalList[" + i + "].titleImgSrc"
        var MeasuringRange = "normalList[" + i + "].MeasuringRange"
        var text = "normalList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/bmi.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(normalList[i])
        })
      }
      if(normalList[i].title == '体脂率')
      {
        var isShow = "normalList[" + i + "].isShow"
        var imgsrc = "normalList[" + i + "].imgsrc"
        var titleImgSrc = "normalList[" + i + "].titleImgSrc"
        var MeasuringRange = "normalList[" + i + "].MeasuringRange"
        var text = "normalList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/bodyFat.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(normalList[i])
        })
      }
      if(normalList[i].title == '肌肉量')
      {
        var isShow = "normalList[" + i + "].isShow"
        var imgsrc = "normalList[" + i + "].imgsrc"
        var titleImgSrc = "normalList[" + i + "].titleImgSrc"
        var MeasuringRange = "normalList[" + i + "].MeasuringRange"
        var text = "normalList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/muscleMass.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(normalList[i])
        })
      }
      if(normalList[i].title == '体年龄')
      {
        var isShow = "normalList[" + i + "].isShow"
        var imgsrc = "normalList[" + i + "].imgsrc"
        var titleImgSrc = "normalList[" + i + "].titleImgSrc"
        var MeasuringRange = "normalList[" + i + "].MeasuringRange"
        var low = "normalList[" + i + "].low"
        var height = "normalList[" + i + "].height"
        var text = "normalList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/bodyAge.png',
          [MeasuringRange]: 'MeasuringRange2',
          [low]: '<',
          [height]: '>',
          [text]: that.setIntroduce(normalList[i])
        })
      }
      if(normalList[i].title == '水分率')
      {
        var isShow = "normalList[" + i + "].isShow"
        var imgsrc = "normalList[" + i + "].imgsrc"
        var titleImgSrc = "normalList[" + i + "].titleImgSrc"
        var MeasuringRange = "normalList[" + i + "].MeasuringRange"
        var text = "normalList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/waterContent.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(normalList[i])
        })
      }
      if(normalList[i].title == '内脏脂肪')
      {
        var isShow = "normalList[" + i + "].isShow"
        var imgsrc = "normalList[" + i + "].imgsrc"
        var titleImgSrc = "normalList[" + i + "].titleImgSrc"
        var MeasuringRange = "normalList[" + i + "].MeasuringRange"
        var text = "normalList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/visceralFatRate.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(normalList[i])
        })
      }
      if(normalList[i].title == '骨量')
      {
        var isShow = "normalList[" + i + "].isShow"
        var imgsrc = "normalList[" + i + "].imgsrc"
        var titleImgSrc = "normalList[" + i + "].titleImgSrc"
        var MeasuringRange = "normalList[" + i + "].MeasuringRange"
        var text = "normalList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/skeletonContent.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(normalList[i])
        })
      }
      if(normalList[i].title == '基础代谢')
      {
        var isShow = "normalList[" + i + "].isShow"
        var imgsrc = "normalList[" + i + "].imgsrc"
        var titleImgSrc = "normalList[" + i + "].titleImgSrc"
        var MeasuringRange = "normalList[" + i + "].MeasuringRange"
        var text = "normalList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/bmr.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(normalList[i])
        })
      }
      if(normalList[i].title == '蛋白质率')
      {
        var isShow = "normalList[" + i + "].isShow"
        var imgsrc = "normalList[" + i + "].imgsrc"
        var titleImgSrc = "normalList[" + i + "].titleImgSrc"
        var MeasuringRange = "normalList[" + i + "].MeasuringRange"
        var text = "normalList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/protein.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(normalList[i])
        })
      }
    }
  },

  //设置偏高列表的区间
  setheightMeasuringRange:function(heightList){
    var that = this
    for(var i in heightList)
    {
      if(heightList[i].title == '体重')
      {
        var isShow = "heightList[" + i + "].isShow"
        var imgsrc = "heightList[" + i + "].imgsrc"
        var titleImgSrc = "heightList[" + i + "].titleImgSrc"
        var MeasuringRange = "heightList[" + i + "].MeasuringRange"
        var text = "heightList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/weight.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(heightList[i])
        })
      }
      if(heightList[i].title == 'BMI')
      {
        var isShow = "heightList[" + i + "].isShow"
        var imgsrc = "heightList[" + i + "].imgsrc"
        var titleImgSrc = "heightList[" + i + "].titleImgSrc"
        var MeasuringRange = "heightList[" + i + "].MeasuringRange"
        var text = "heightList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/bmi.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(heightList[i])
        })
      }
      if(heightList[i].title == '体脂率')
      {
        var isShow = "heightList[" + i + "].isShow"
        var imgsrc = "heightList[" + i + "].imgsrc"
        var titleImgSrc = "heightList[" + i + "].titleImgSrc"
        var MeasuringRange = "heightList[" + i + "].MeasuringRange"
        var text = "heightList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/bodyFat.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(heightList[i])
        })
      }
      if(heightList[i].title == '肌肉量')
      {
        var isShow = "heightList[" + i + "].isShow"
        var imgsrc = "heightList[" + i + "].imgsrc"
        var titleImgSrc = "heightList[" + i + "].titleImgSrc"
        var MeasuringRange = "heightList[" + i + "].MeasuringRange"
        var text = "heightList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/muscleMass.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(heightList[i])
        })
      }
      if(heightList[i].title == '体年龄')
      {
        var isShow = "heightList[" + i + "].isShow"
        var imgsrc = "heightList[" + i + "].imgsrc"
        var titleImgSrc = "heightList[" + i + "].titleImgSrc"
        var MeasuringRange = "heightList[" + i + "].MeasuringRange"
        var low = "heightList[" + i + "].low"
        var height = "heightList[" + i + "].height"
        var text = "heightList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/bodyAge.png',
          [MeasuringRange]: 'MeasuringRange2',
          [low]: '<',
          [height]: '>',
          [text]: that.setIntroduce(heightList[i])
        })
      }
      if(heightList[i].title == '水分率')
      {
        var isShow = "heightList[" + i + "].isShow"
        var imgsrc = "heightList[" + i + "].imgsrc"
        var titleImgSrc = "heightList[" + i + "].titleImgSrc"
        var MeasuringRange = "heightList[" + i + "].MeasuringRange"
        var text = "heightList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/waterContent.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(heightList[i])
        })
      }
      if(heightList[i].title == '内脏脂肪')
      {
        var isShow = "heightList[" + i + "].isShow"
        var imgsrc = "heightList[" + i + "].imgsrc"
        var titleImgSrc = "heightList[" + i + "].titleImgSrc"
        var MeasuringRange = "heightList[" + i + "].MeasuringRange"
        var text = "heightList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/visceralFatRate.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(heightList[i])
        })
      }
      if(heightList[i].title == '骨量')
      {
        var isShow = "heightList[" + i + "].isShow"
        var imgsrc = "heightList[" + i + "].imgsrc"
        var titleImgSrc = "heightList[" + i + "].titleImgSrc"
        var MeasuringRange = "heightList[" + i + "].MeasuringRange"
        var text = "heightList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/skeletonContent.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(heightList[i])
        })
      }
      if(heightList[i].title == '基础代谢')
      {
        var isShow = "heightList[" + i + "].isShow"
        var imgsrc = "heightList[" + i + "].imgsrc"
        var titleImgSrc = "heightList[" + i + "].titleImgSrc"
        var MeasuringRange = "heightList[" + i + "].MeasuringRange"
        var text = "heightList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/bmr.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(heightList[i])
        })
      }
      if(heightList[i].title == '蛋白质率')
      {
        var isShow = "heightList[" + i + "].isShow"
        var imgsrc = "heightList[" + i + "].imgsrc"
        var titleImgSrc = "heightList[" + i + "].titleImgSrc"
        var MeasuringRange = "heightList[" + i + "].MeasuringRange"
        var text = "heightList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/protein.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(heightList[i])
        })
      }
    }
  },

  //设置偏低列表的区间
  setlowMeasuringRange:function(lowList){
    var that = this
    for(var i in lowList)
    {
      if(lowList[i].title == '体重')
      {
        var isShow = "lowList[" + i + "].isShow"
        var imgsrc = "lowList[" + i + "].imgsrc"
        var titleImgSrc = "lowList[" + i + "].titleImgSrc"
        var MeasuringRange = "lowList[" + i + "].MeasuringRange"
        var text = "lowList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/weight.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(lowList[i])
        })
      }
      if(lowList[i].title == 'BMI')
      {
        var isShow = "lowList[" + i + "].isShow"
        var imgsrc = "lowList[" + i + "].imgsrc"
        var titleImgSrc = "lowList[" + i + "].titleImgSrc"
        var MeasuringRange = "lowList[" + i + "].MeasuringRange"
        var text = "lowList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/bmi.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(lowList[i])
        })
      }
      if(lowList[i].title == '体脂率')
      {
        var isShow = "lowList[" + i + "].isShow"
        var imgsrc = "lowList[" + i + "].imgsrc"
        var titleImgSrc = "lowList[" + i + "].titleImgSrc"
        var MeasuringRange = "lowList[" + i + "].MeasuringRange"
        var text = "lowList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/bodyFat.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(lowList[i])
        })
      }
      if(lowList[i].title == '肌肉量')
      {
        var isShow = "lowList[" + i + "].isShow"
        var imgsrc = "lowList[" + i + "].imgsrc"
        var titleImgSrc = "lowList[" + i + "].titleImgSrc"
        var MeasuringRange = "lowList[" + i + "].MeasuringRange"
        var text = "lowList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/muscleMass.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(lowList[i])
        })
      }
      if(lowList[i].title == '体年龄')
      {
        var isShow = "lowList[" + i + "].isShow"
        var imgsrc = "lowList[" + i + "].imgsrc"
        var titleImgSrc = "lowList[" + i + "].titleImgSrc"
        var MeasuringRange = "lowList[" + i + "].MeasuringRange"
        var low = "lowList[" + i + "].low"
        var height = "lowList[" + i + "].height"
        var text = "lowList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/bodyAge.png',
          [MeasuringRange]: 'MeasuringRange2',
          [low]: '<',
          [height]: '>',
          [text]: that.setIntroduce(lowList[i])
        })
      }
      if(lowList[i].title == '水分率')
      {
        var isShow = "lowList[" + i + "].isShow"
        var imgsrc = "lowList[" + i + "].imgsrc"
        var titleImgSrc = "lowList[" + i + "].titleImgSrc"
        var MeasuringRange = "lowList[" + i + "].MeasuringRange"
        var text = "lowList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/waterContent.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(lowList[i])
        })
      }
      if(lowList[i].title == '内脏脂肪')
      {
        var isShow = "lowList[" + i + "].isShow"
        var imgsrc = "lowList[" + i + "].imgsrc"
        var titleImgSrc = "lowList[" + i + "].titleImgSrc"
        var MeasuringRange = "lowList[" + i + "].MeasuringRange"
        var text = "lowList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/visceralFatRate.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(lowList[i])
        })
      }
      if(lowList[i].title == '骨量')
      {
        var isShow = "lowList[" + i + "].isShow"
        var imgsrc = "lowList[" + i + "].imgsrc"
        var titleImgSrc = "lowList[" + i + "].titleImgSrc"
        var MeasuringRange = "lowList[" + i + "].MeasuringRange"
        var text = "lowList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/skeletonContent.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(lowList[i])
        })
      }
      if(lowList[i].title == '基础代谢')
      {
        var isShow = "lowList[" + i + "].isShow"
        var imgsrc = "lowList[" + i + "].imgsrc"
        var titleImgSrc = "lowList[" + i + "].titleImgSrc"
        var MeasuringRange = "lowList[" + i + "].MeasuringRange"
        var text = "lowList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/bmr.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(lowList[i])
        })
      }
      if(lowList[i].title == '蛋白质率')
      {
        var isShow = "lowList[" + i + "].isShow"
        var imgsrc = "lowList[" + i + "].imgsrc"
        var titleImgSrc = "lowList[" + i + "].titleImgSrc"
        var MeasuringRange = "lowList[" + i + "].MeasuringRange"
        var text = "lowList[" + i + "].text"
        that.setData({
          [isShow]: false,
          [imgsrc]: '/resources/healthData/down.png',
          [titleImgSrc]: '/resources/healthData/icon/protein.png',
          [MeasuringRange]: 'MeasuringRange1',
          [text]: that.setIntroduce(lowList[i])
        })
      }
    }
    // console.log(lowList)
  },

  //设置单位（标准）
  setBzUnit:function(normalList){
    var that = this
    for(var i in normalList){
      if(normalList[i].title == '体重')
      {
        var unit = "normalList[" + i + "].unit"
        that.setData({
          [unit]: 'kg',
        })
      }
      if(normalList[i].title == 'BMI')
      {
        var unit = "normalList[" + i + "].unit"
        that.setData({
          [unit]: '',
        })
      }
      if(normalList[i].title == '体脂率')
      {
        var unit = "normalList[" + i + "].unit"
        that.setData({
          [unit]: '%',
        })
      }
      if(normalList[i].title == '肌肉量')
      {
        var unit = "normalList[" + i + "].unit"
        that.setData({
          [unit]: 'kg',
        })
      }
      if(normalList[i].title == '体年龄')
      {
        var unit = "normalList[" + i + "].unit"
        that.setData({
          [unit]: '岁',
        })
      }
      if(normalList[i].title == '水分率')
      {
        var unit = "normalList[" + i + "].unit"
        that.setData({
          [unit]: '%',
        })
      }
      if(normalList[i].title == '内脏脂肪')
      {
        var unit = "normalList[" + i + "].unit"
        that.setData({
          [unit]: '',
        })
      }
      if(normalList[i].title == '骨量')
      {
        var unit = "normalList[" + i + "].unit"
        that.setData({
          [unit]: 'kg',
        })
      }
      if(normalList[i].title == '基础代谢')
      {
        var unit = "normalList[" + i + "].unit"
        that.setData({
          [unit]: 'kcal',
        })
      }
      if(normalList[i].title == '蛋白质率')
      {
        var unit = "normalList[" + i + "].unit"
        that.setData({
          [unit]: '%',
        })
      }
    }
  },

  //设置单位（偏低）
  setLowUnit:function(lowList){
    var that = this
    for(var i in lowList){
      if(lowList[i].title == '体重')
      {
        var unit = "lowList[" + i + "].unit"
        that.setData({
          [unit]: 'kg',
        })
      }
      if(lowList[i].title == 'BMI')
      {
        var unit = "lowList[" + i + "].unit"
        that.setData({
          [unit]: '',
        })
      }
      if(lowList[i].title == '体脂率')
      {
        var unit = "lowList[" + i + "].unit"
        that.setData({
          [unit]: '%',
        })
      }
      if(lowList[i].title == '肌肉量')
      {
        var unit = "lowList[" + i + "].unit"
        that.setData({
          [unit]: 'kg',
        })
      }
      if(lowList[i].title == '体年龄')
      {
        var unit = "lowList[" + i + "].unit"
        that.setData({
          [unit]: '岁',
        })
      }
      if(lowList[i].title == '水分率')
      {
        var unit = "lowList[" + i + "].unit"
        that.setData({
          [unit]: '%',
        })
      }
      if(lowList[i].title == '内脏脂肪')
      {
        var unit = "lowList[" + i + "].unit"
        that.setData({
          [unit]: '',
        })
      }
      if(lowList[i].title == '骨量')
      {
        var unit = "lowList[" + i + "].unit"
        that.setData({
          [unit]: 'kg',
        })
      }
      if(lowList[i].title == '基础代谢')
      {
        var unit = "lowList[" + i + "].unit"
        that.setData({
          [unit]: 'kcal',
        })
      }
      if(lowList[i].title == '蛋白质率')
      {
        var unit = "lowList[" + i + "].unit"
        that.setData({
          [unit]: '%',
        })
      }
    }
  },

  //设置单位（偏高）
  setHeightUnit:function(heightList){
    var that = this
    for(var i in heightList){
      if(heightList[i].title == '体重')
      {
        var unit = "heightList[" + i + "].unit"
        that.setData({
          [unit]: 'kg',
        })
      }
      if(heightList[i].title == 'BMI')
      {
        var unit = "heightList[" + i + "].unit"
        that.setData({
          [unit]: '',
        })
      }
      if(heightList[i].title == '体脂率')
      {
        var unit = "heightList[" + i + "].unit"
        that.setData({
          [unit]: '%',
        })
      }
      if(heightList[i].title == '肌肉量')
      {
        var unit = "heightList[" + i + "].unit"
        that.setData({
          [unit]: 'kg',
        })
      }
      if(heightList[i].title == '体年龄')
      {
        var unit = "heightList[" + i + "].unit"
        that.setData({
          [unit]: '岁',
        })
      }
      if(heightList[i].title == '水分率')
      {
        var unit = "heightList[" + i + "].unit"
        that.setData({
          [unit]: '%',
        })
      }
      if(heightList[i].title == '内脏脂肪')
      {
        var unit = "heightList[" + i + "].unit"
        that.setData({
          [unit]: '',
        })
      }
      if(heightList[i].title == '骨量')
      {
        var unit = "heightList[" + i + "].unit"
        that.setData({
          [unit]: 'kg',
        })
      }
      if(heightList[i].title == '基础代谢')
      {
        var unit = "heightList[" + i + "].unit"
        that.setData({
          [unit]: 'kcal',
        })
      }
      if(heightList[i].title == '蛋白质率')
      {
        var unit = "heightList[" + i + "].unit"
        that.setData({
          [unit]: '%',
        })
      }
    }
  },

  //点击显示内容
  showContent:function(e){
    var that = this 
    var index = e.currentTarget.dataset.indx
    if(e.currentTarget.dataset.main == "标准"){
      var bz = that.data.normalList;
      if(bz[index].isShow == false)
      {
        bz[index].isShow = true;
        bz[index].imgsrc = '/resources/healthData/up.png'
      }
      else{
        bz[index].isShow = false;
        bz[index].imgsrc = '/resources/healthData/down.png'
      }
      that.setData({
        normalList: bz
      })
    }
    if(e.currentTarget.dataset.main == "偏高"){
      var height = that.data.heightList;
      if(height[index].isShow == false)
      {
        height[index].isShow = true;
        height[index].imgsrc = '/resources/healthData/up.png'
      }
      else{
        height[index].isShow = false;
        height[index].imgsrc = '/resources/healthData/down.png'
      }
      that.setData({
        heightList: height
      })
    }
    if(e.currentTarget.dataset.main == "偏低"){
      var low = that.data.lowList;
      if(low[index].isShow == false)
      {
        low[index].isShow = true;
        low[index].imgsrc = '/resources/healthData/up.png'
      }
      else{
        low[index].isShow = false;
        low[index].imgsrc = '/resources/healthData/down.png'
      }
      that.setData({
        lowList: low
      })
    }
    // that.setData({
    //   isShow: !that.data.isShow
    // })
  },

  setIntroduce:function(arr){
    // console.log(arr)
    var text = ''
    switch (arr.title) {
      case '体重':
      case 'BMI':
        switch (arr.type) {
          case '偏瘦':
            text = '根据数据显示，您现在的BMI值小于正常范围，体重偏瘦，容易出现身体虚弱，抵抗力较差， 易出现疲乏，体力不足，怕冷等现象。所以建议您定期体检，时刻关注身体情况，适当补充营养，保持在正常体重范围，同时一定要配合运动，提高体能的同时又能塑造完美体形'
            break;
          case '标准':
            text = '根据数据显示显示，您现在的BMI数值属正常范围，一定和您日常良好的运动、饮食习惯相关。为了保持良好的身体情况，请继续保持下去'
            break;
          case '偏胖':
          case '肥胖':
          case '超重':
            text = '根据数据显示，您现在的BMI值属于超重范围，除了对外形的影响外，对心脏、血压、关节、内脏的负担会较大，建议您使用有氧结合力量的方式进行运动，降低体重与体脂，获得美丽的同时，也要拥有健康！'
            break;
          case '重度肥胖':
            text = '根据数据显示，您现在的BMI值属于严重超标，肥胖是目前影响身体健康的一个重要因素，会增加多种疾病的患病风险，对心脏、血压、关节、内脏的负担会较大。建议您尽快通过健康管理降低体重'
            break;
        }
        break;
      case '体脂率':
        switch (arr.type) {
          case '偏瘦':
            text = '根据数据显示您的体脂肪偏少，脂肪如果严重过少甚至会影响到我们的身体健康，容易出现身体虚弱，抵抗力较差， 易出现疲乏，体力不足，怕冷等现象，月经紊乱，面黄肌瘦等等。建议您适当补充营养，让体脂肪含量保持在健康范围'
            break;
          case '标准':
            text = '根据数据显示显示，您现在的BMI数值属正常范围，一定和您日常良好的运动、饮食习惯相关。为了保持良好的身体情况，请继续保持下去'
            break;
          case '轻度肥胖':
            text = '根据数据显示，您的体脂含量相对偏高。在平时的生活当中注意饮食控制。少饮酒，控制饮食速度，饭后不要马上坐下。控制食物摄入的总热量。在运动上以有氧训练为主配合力量训练。从而改善健康'
            break;
          case '偏胖':
          case '肥胖':
            text = '根据数据显示，您的体脂率含量超过正常范围，表明运动不足、建议您检测自己的血压、血糖、肝功能等情况，是否潜藏危害健康因子。再通过健康的饮食控制、与规律的运动及改变生活方式，提升生活质量'
            break;
          case '极度肥胖':
            text = '根据数据显示，您的体脂率严重超标，过多脂肪会粘附血管壁，使血液变得粘稠，流动速度滞缓。增加患心脑血管疾病的风险。建议您调整日常的生活习惯，控制油炸类等高油的食物，同时配合有氧结合力量的方式进行运动，降低体重与内脏脂肪含量'
            break;
        }
        break;
      case '肌肉量':
        switch (arr.type) {
          case '不足':
            text = '根据数据显示您的肌肉含量偏弱，建议您加强力量训练，提高肌肉质量，同时还可以提高运动能力。减少运动损伤。获得更好的运动效果'
            break;
          case '标准':
            text = '根据数据显示您的肌肉含量标准，良好的肌肉含量可以让我们保持高消耗热量的代谢，维持身材不容易发胖，建议继续配合规律的运动频率，提高肌肉质量，增强体质，提升运动表现'
            break;
          case '优秀':
            text = '根据测试数据显示，您的肌肉含量偏多，拥有非常良好的代谢功能，可以继续提高肌肉质量，以及基础代谢，坚持良好的运动与健康的饮食习惯，形成易瘦体质，拥有紧致身材'
            break;
        }
        break;
      case '水分率':
        switch (arr.type) {
          case '不足':
            text = '根据数据显示，您体内的水份含量偏低，由于水分在身体中占很大比例，对水分率的测量也可以反映出你的胖瘦水平。减肥期间水分率测量结果的变化还可以反映减肥方向是否正确，减肥过程中一味地减低身体水分率，反而会令身体脂肪率上升。如果在减肥的过程中出现水分大幅减少的情况，可能就意味减肥方法有些偏差，应该采用更为健康的进行减脂'
            break;
          case '标准':
            text = '根据数据显示，您体内的水分含量正常，建议您在天气炎热或者运动量大出汗多的时候，饮水量要相应增加，而每天早起第一杯水喝300毫升左右最佳。需要注意的是，每天喝水的时候，最好不要以各种的饮料代替，其补充水分的同时也补充了大量的糖分、热量，容易让人发胖'
            break;
          case '偏高':
            text = '根据数据显示，您体内的水分含量偏高，水分率过高，可能会产生胸、腹水的疾患和局部组织水肿，心、肺、肾衰竭及全身性水肿症状。需引起注意或及时就医。'
            break;
        }
        break;
      case '内脏脂肪':
        switch (arr.type) {
          case '偏低':
            text = '根据数据显示，您的内脏脂肪含量偏低，内脏脂肪过低，说明您的身体过瘦，一定量的内脏脂肪其实是人体必需的，因为内脏脂肪围绕着人的脏器，对人的内脏起着支撑、稳定和保护的作用。'
            break;
          case '正常':
            text = '根据数据显示，您的内脏脂肪含量正常，这与您日常健康的饮食和良好的运动有关系，继续保持您良好的生活习惯，清淡均衡的饮食和科学规律的运动'
            break;
          case '警惕':
            text = '根据数据显示，您的内脏脂肪指标偏高，需要配合科学的运动与营养均衡的饮食方式双管齐下来减少内脏脂肪'
            break;
          case '危险':
            text = '根据数据显示，您的内脏脂肪已严重超标，严重影响到健康，引发身体代谢紊乱的表现，长期内脏脂肪会导致高血脂、心脑血管疾病、身体器官机能下降等并发症'
            break;
        }
        break;
      case '骨量':
        switch (arr.type) {
          case '不足':
            text = '根据数据显示，您的骨骼含量偏低，随着年纪的增加骨量会开始出现不可逆转的渐渐流失，可能会出现脆性骨折为严重的骨质疏松症。建议您多多进行体能活动，增加骨骼含量，强身健体'
            break;
          case '标准':
              text = '根据数据显示，您的骨骼含量正常，建议您多做运动可以增加骨骼密度，减少骨质流失，降低骨质疏松的风险。晒太阳可以促进维生素D的生成，而维生素D又是促进钙质吸收的关键。'
              break;
          case '优秀':
              text = '根据数据显示，您的骨骼含量良好，保持良好的生活习惯与运动频率，可以很好增强骨骼含量，增加身体活力。'
              break;
        }
        break;
      case '基础代谢':
        switch (arr.type) {
          case '不足':
            text = '根据健康报告数据分析您现在基础代谢偏低，建议您多进行力量训练，并且力量训练本身能够刺激身体分泌激素，增加你的基础代谢。基础代谢提升之后身体消耗热量的速度提升，让减肥事半功倍。'
            break;
          case '标准':
            text = '根据健康报告数据分析您现在基础代谢属于正常数值，可以适当加强力量训练，提升肌肉质量、加速体脂率的代谢让咱们的体型更佳紧致。'
            break;
        }
        break;
      case '体年龄':
        switch (arr.type) {
          case '年轻':
            text = '根据数据显示，您的身体年龄相较于自身年龄较年轻，内脏脂肪也相对较低。平时注意饮食上适当的增加热量摄入和每 周保持3~4次适量的运动。让你的身体更建康'
            break;
          case '正常':
            text = ''
            break;
          case '偏大':
            text = '根据数据显示，您的身体年龄相较于自身年龄偏大，身体状态中等。在平时的正常生活当中 ， 注意规律的作息和饮食。饮食上注意热量的摄入，避免油炸食物，高油脂食物，饮食清淡八分饱。保证每周3~5次的适当训练，有氧训练为主导。提高心肺功能和肌肉力量 ，降低体重。让身体年龄降低'
            break;
        }
        break;
      case '蛋白质率':
        switch (arr.type) {
          case '不足':
            text = '根据数据显示，您的身蛋白质率偏低，蛋白质偏低，说明饮食中摄入的瘦肉类、海鲜类、蛋奶类不足或者肠胃吸收不良，如果长期如此，机体会消耗自身肌肉，造成或加重肌肉衰减，应适量增加蛋白质摄入，改善肠胃吸收，增加锻炼量'
            break;
          case '标准':
            text = '根据数据显示，您的身蛋白质率正常，蛋白质可以提供能量，维持身体正常生理，也是合成肌肉的原料，一日三餐中如果没有充足的蛋白质，成年人体质、体力和免疫力低下，精力不足；老年人衰老加快，老态龙钟；病人康复延迟，元气难以恢复。'
            break;
          case '偏高':
            text = '根据数据显示，您的身蛋白质率偏高，蛋白质偏高，说明摄入的肉类、海鲜类、蛋奶类或精细主食过多，或者是代谢异常，易引起肥胖、三高症或增加肾脏负担。'
            break;
        }
        break;
    }
    return text 
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },
  
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    // return {
    //   title: 'PAPN体重管理',
    //   path: 'pages/index/index',
    //   success: function(res) {
    //     // res.shareTickets 
    //   },
    //   fail: function(res) {
    //       console.log(res)
    //   }
    // }
  }
})